{include file="./headStart.tpl"}
{literal}
<script type="text/javascript">
$(document).ready(function() {
	$("#productHide").hide();  
	$(".add").click(function(){ 
   $("#one").clone(true).appendTo("#mainDiv").find('input[type="text"]').val('');    
   addRow();
  });
  $("#srNoInsert").blur(function() {
    srnoMatch($(this));
  });
  $(".classSubcategory").change(function(){
    subCategoryCombo($(this));
  });
  //for party address:Start
  $(".supplierId").change(function(){
    var dataString = "supplierId=" + $(".supplierId").val();
	  $.ajax({ 
      type: "GET",
      url:  "supplierddressAj.php",
      data: dataString,
      success: function(data){
        $("#addressType").val(data);
      }
    });
  });
  //for party address:End
})
//function for srNo:Start
function srnoMatch(srObj)
{
	if($(srObj).val() < {/literal}{$srnoSelected}{literal})
	{
		alert("Please Insert max sr no!");
		setTimeout(function(){srObj.focus()}, 1);
	}  
}
function addRow() 
{
  var countSr = 1;
  $('.srNoClass').each(function()
  {
    this.value = countSr++;
  });
  return false;
}
//function for srNo:End
//function for delete :Start
function deleteRow()
{
  $('.delete').click(function()
  {
    var countSr = 1;
    $(this).parent().parent().remove();
    $('.srNoClass').each(function(){
          this.value = countSr++;
        });
    return false;
  });
}
//function for delete :End
//function for get item :Start
function subCategoryCombo(itemObj)
{
  var rowCount = 0;
  $('.classSubcategory').each(function()
  {
    rowCount++;
  });
    var dataString1 = "subCategoryId=" + $(itemObj).val() +"&rowCount=" + rowCount; 
  
  $.ajax({
    url: "./itemAj.php",
    cache: false,
    data: dataString1,
    success:function(data){
    	$(itemObj).next("span").html(data);
    	$(itemObj).focus();
    	$("#productHide").show();
    	$(".addItem").hide();
    }
  });
}
//function for get item :End
function formvalidation()
{
	if($("#partyId").val() == 0)
	{
		alert("Please select any Party");
		$("#partyId").focus();
    return false;
	}
  if($(".supplierId").val() == 0)
	{
		alert("Please select any Supplier");
		$(".supplierId").focus();
    return false;
	}
	if($(".classSubcategory").val() == 0)
	{
		alert("Please select any Sub Category");
		$(".classSubcategory").focus();
    return false;
	}
	if($(".itemIdClass").val() == 0)
	{
		alert("Please select any Product");
		$(".itemIdClass").focus();
    return false;
	}
	if($(".quantity").val() == "")
	{
		alert("Quantity is blank");
		$(".quantity").focus();
    return false;
	}
	if(isNaN($(".quantity").val()))
	{
		alert("Please Enter valid Quantity");
		$(".quantity").focus();
    return false;
	}
}
</script>
{/literal}
{include file="./headEnd.tpl"}
<form name="formrRndR" action="{$smarty.server.PHP_SELF}" id="formrRndR" method="post">
<table align="center" border="1" cellpadding="2" cellspacing="1" >
<tr>
  <td align="center" class="table1" colspan="10">R AND R</td>
</tr>
<tr>
  <td align="left" class="table2" >Sr.No.: </td>
  <td class="table2" align="left">
  	<input type="text" size="5" id="srNo" value="{$srnoSelected}" DISABLED=DISABLED>
  	<input type="hidden" size="5" name="srNo" id="srNo" value="{$srnoSelected}">
  </td>
  <td align="left" class="table2" >Customer.: </td>
  <td class="table2">
    <select name="partyId" class="partyId" id="partyId">
      <option value="0">Select Name</option>
      {html_options values=$customerArr.partyId output=$customerArr.companyName}
    </select>
  </td>
</tr>
<tr>
  <td align="left" class="table2" >Complaint Date: </td>
  <td NOWRAP class="table2">
    {html_select_date prefix="complaint" time="$delivaryDateSelected" start_year="-3" end_year="+1" month_format="%m" field_order="DMY" 
     day_value_format="%02d" disabled=disabled}
  </td>
  <td align="left" class="table2" >Target Date: </td>
  <td NOWRAP class="table2">
    {html_select_date prefix="target" time="$delivaryDateSelected" start_year="-3" end_year="+1" month_format="%m" field_order="DMY" 
     day_value_format="%02d"}
  </td>
</tr>
<tr>
  <td align="left" class="table2" NOWRAP>Send For<br/>Repair : </td>
  <td class="table2">
    <select name="supplierId" class="supplierId">
      <option value="0">Select Name</option>
      {html_options values=$supplierArr.supplierId output=$supplierArr.companyName}
    </select>
  </td>
  <td align="left" class="table2">Address : </td>
  <td class="table2" colspan="6"><textarea name="address" rows="4" cols="50" id="addressType">{$addressSelected}</textarea></td>
</tr>
</table>
</br>
<table align="center" border="1"  cellpadding="1" cellspacing="0">
<tr>
  <td colspan="4"> 
    <table align="center" border="0" id="dataTable" width="100%" cellpadding="1" cellspacing="0">
      <tr>
        <th align="center" class="table1">SR. NO.</th>
        <th align="left" class="table1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sub Category 
          <div style="display:inline;" id="productHide"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            Product
          </div>
        </th>
        <th align="center" class="table1">Quantity</th>
        <th align="center" class="table1">Desc. of Complaints</th>
        <th align="center" class="table1">&nbsp;</th>
        <th align="center" class="table1">&nbsp;</th>
      </tr>
      <tbody id="mainDiv">
      <tr id="one">
        <td class="table2"><input type="text" class="srNoClass" name="srNo[]" id="srNo" value="1" size="2" DISABLED></td>
        <td class="table2" NOWRAP>
          <select name="subCategoryId[]" id="subCategoryId" class="classSubcategory">
        	  <option value=0 >Select Sub Category </option>
        	  {html_options values=$subCatArr.subCategoryId output=$subCatArr.subCategoryName}
        	</select>
          <span></span>
        </td>
        <td class="table2"><input type="text" class="quantity" name="quantity[]" id="quantity[]"></td>
        <td class="table3"><textarea class="complaintDesc" style="text-align:right" name="complaintDesc[]"></textarea></td>
        <td class="table3"><input type="button" value="Add" name="add" class="add" /></td>
        <td class="table3"><input type="button" value="Delete" name="deleteBtn"  class="delete" onclick="deleteRow()"/></td>
      </tr>
      </tbody>
    </table>
    <table align="center">
      <tr>
        <td colspan="9">
          <input class="button" type="submit" value="SUBMIT" name="submitBtn" id="submitBtn" onclick="return formvalidation(this);"/>
          <input class="button" type="submit" name="printBtn" id="printBtn" value="Print" onclick="return formvalidation(this);" />
    </td>
  </tr>
</table>
  </td>
</tr>
</table>
</form>
{include file="footer.tpl"}